HTML5: 20 Lessons to Successful Web Development by Nixon Robin

HTML5: 20 Lessons to Successful Web Development by Nixon Robin

Author:Nixon, Robin [Nixon, Robin]
Language: eng
Format: mobi, azw3, epub
Publisher: McGraw-Hill Education
Published: 2015-01-27T08:00:00+00:00


The textAlign Property

But there’s more to writing text to a canvas than that because there are three properties you can pass values to that will further customize the way text appears. For example, using the textAlign property, you can specify the alignment of the text out of the values start, end, left, right, and center. So, to center some text, you could set the property like this:

As you may have noticed, in order to properly center the text, the call to strokeText() needed its horizontal offset changed from 20 in the previous example to 205, because that is half the width of the canvas (which is 410 pixels wide), and the result is shown in Figure 11-2.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.